<!DOCTYPE html>
<html>
<head>
<title>projectDetail.html</title>

<meta name="keywords" content="keyword1,keyword2,keyword3">
<meta name="description" content="this is my page">
<meta name="content-type" content="text/html; charset=UTF-8">

<link rel="stylesheet" href="/Hospital/lib/layui-v2.1.6/layui/css/layui.css" media="all">
<style type="text/css">
select {
	height: 38px;
	line-height: 1.3;
	line-height: 38px\9;
	border-width: 1px;
	border-style: solid;
	background-color: #fff;
	border-radius: 2px;
	width: 100%;
}

h1 {
	color: #c2c2c2;
	line-height: 25px;
	font-size: 16px;
	text-align: center;
	margin-top : 5px;
}

.row {
	margin-top: 10px;
}
</style>
</head>

<body>
	<div id="div_fund" class="layui-form layui-container" style="">
		<div class="layui-row row">
			<div class="layui-col-xs4 layui-col-xs-offset1 layui-col-md2 layui-col-md-offset2">
				<span class="layui-form-label">项目名称: </span>
			</div>
			<div class="layui-col-xs5 layui-col-md2 ">
				<input id="fund_projectName" class="layui-input" type="text" placeholder="不可为空">
			</div>
		</div>

		<div class="layui-row row">
			<div class="layui-col-xs4 layui-col-xs-offset1 layui-col-md2 layui-col-md-offset2">
				<span class="layui-form-label">项目状态: </span>
			</div>
			<div class="layui-col-xs5 layui-col-md2">
				<select id="fund_status" name="fund_status" class="layui-input-inline">
					<option value="0">启用</option>
					<option value="1">禁用</option>
				</select>
			</div>
		</div>

		<div class="layui-row row">
			<div class="layui-col-xs4 layui-col-xs-offset1 layui-col-md2 layui-col-md-offset2">
				<span class="layui-form-label">支出类型: </span>
			</div>
			<div class="layui-col-xs5 layui-col-md2">
				<select id="fund_type" name="fund_type" class="layui-input-inline">
					<option value="0">收入</option>
					<option value="1">支出</option>
				</select>
			</div>
		</div>

		<div class="layui-row row div_time">
			<div class="layui-col-xs4 layui-col-xs-offset1 layui-col-md2 layui-col-md-offset2">
				<span class="layui-form-label">创建时间: </span>
			</div>
			<div class="layui-col-xs5 layui-col-md2">
				<input id="fund_createTime" class="layui-input" type="text" disabled>
			</div>
		</div>

		<div class="layui-row row div_time">
			<div class="layui-col-xs4 layui-col-xs-offset1 layui-col-md2 layui-col-md-offset2">
				<span class="layui-form-label">修改时间: </span>
			</div>
			<div class="layui-col-xs5 layui-col-md2">
				<input id="fund_alterTime" class="layui-input" type="text" disabled>
			</div>
		</div>
	</div>
	<div id="div_treat" class="layui-form layui-container" style="">
		<div class="layui-row row">
			<div class="layui-col-xs3 layui-col-xs-offset1 layui-col-md2 layui-col-md-offset2">
				<span class="layui-form-label">项目名称: </span>
			</div>
			<div class="layui-col-xs4 layui-col-md2 ">
				<input id="treat_projectName" class="layui-input" type="text">
			</div>
		</div>

		<div class="layui-row row">
			<div class="layui-col-xs3 layui-col-xs-offset1 layui-col-md2 layui-col-md-offset2">
				<span class="layui-form-label">治疗单价: </span>
			</div>
			<div class="layui-col-xs4 layui-col-md2 ">
				<input id="treat_unitPrice" class="layui-input" type="text">
			</div>
		</div>

		<div class="layui-row row">
			<div class="layui-col-xs3 layui-col-xs-offset1 layui-col-md2 layui-col-md-offset2">
				<span class="layui-form-label">医生抽成: </span>
			</div>
			<div class="layui-col-xs4 layui-col-md2 ">
				<input id="treat_doctorCost" class="layui-input" type="text">
			</div>
			<div class="layui-col-xs3 layui-col-md2 ">
				<h1>[0.00-100.00](%)</h1>
			</div>
		</div>

		<div class="layui-row row">
			<div class="layui-col-xs3 layui-col-xs-offset1 layui-col-md2 layui-col-md-offset2">
				<span class="layui-form-label">分院抽成: </span>
			</div>
			<div class="layui-col-xs4 layui-col-md2 ">
				<input id="treat_clinicCost" class="layui-input" type="text">
			</div>
			<div class="layui-col-xs3 layui-col-md2 ">
				<h1>[0.00-100.00](%)</h1>
			</div>
		</div>

		<div class="layui-row row">
			<div class="layui-col-xs3 layui-col-xs-offset1 layui-col-md2 layui-col-md-offset2">
				<span class="layui-form-label">执行者抽成: </span>
			</div>
			<div class="layui-col-xs4 layui-col-md2 ">
				<input id="treat_excutorCost" class="layui-input" type="text">
			</div>
			<div class="layui-col-xs3 layui-col-md2 ">
				<h1>[0.00-100.00](%)</h1>
			</div>
		</div>

		<div class="layui-row row">
			<div class="layui-col-xs3 layui-col-xs-offset1 layui-col-md2 layui-col-md-offset2">
				<span class="layui-form-label">项目状态: </span>
			</div>
			<div class="layui-col-xs4 layui-col-md2">
				<select id="treat_status" name="treat_status" class="layui-input-inline">
					<option value="0">启用</option>
					<option value="1">禁用</option>
				</select>
			</div>
		</div>

		<div class="layui-row row">
			<div class="layui-col-xs3 layui-col-xs-offset1 layui-col-md2 layui-col-md-offset2">
				<span class="layui-form-label">支出类型: </span>
			</div>
			<div class="layui-col-xs4 layui-col-md2">
				<select id="treat_type" name="treat_type" class="layui-input-inline" disabled>
					<option value="0">收入</option>
					<option value="1">支出</option>
				</select>
			</div>
		</div>

		<div class="layui-row row div_time">
			<div class="layui-col-xs3 layui-col-xs-offset1 layui-col-md2 layui-col-md-offset2">
				<span class="layui-form-label">创建时间: </span>
			</div>
			<div class="layui-col-xs4 layui-col-md2">
				<input id="treat_createTime" class="layui-input" type="text" disabled>
			</div>
		</div>

		<div class="layui-row row div_time">
			<div class="layui-col-xs3 layui-col-xs-offset1 layui-col-md2 layui-col-md-offset2">
				<span class="layui-form-label">修改时间: </span>
			</div>
			<div class="layui-col-xs4 layui-col-md2">
				<input id="treat_alterTime" class="layui-input" type="text" disabled>
			</div>
		</div>
	</div>
</body>
<script src="/Hospital/lib/jquery.min.js" charset="utf-8"></script>
<script src="/Hospital/lib/layui-v2.1.6/layui/layui.js" charset="utf-8"></script>
<script type="text/javascript">
	layui.use('form', function() {
		var form = layui.form;
		initFrame();//初始化窗口
		initFocusout();//数值设置
		//初始化窗口
		function initFrame() {
			var operator = localStorage.getItem("projectTable_operator");
			var category = localStorage.getItem("projectTable_category");
			//治疗项目
			if (category == 1) {
				$("#div_fund").css({
					"display" : "none"
				});

				//新增按钮
				if (operator == 1) {
					$(".div_time").css({
						"display" : "none"
					});
					$("#treat_status").attr("disabled", true);
					$("#treat_unitPrice").val(toDecimal(0));
					$("#treat_doctorCost").val(toDecimal(0));
					$("#treat_excutorCost").val(toDecimal(0));
					$("#treat_clinicCost").val(toDecimal(0));

					form.render();
				}
				//编辑按钮
				if (operator == 2) {
					var projectDetail = JSON.parse(localStorage.getItem("projectDetail"));
					$("#treat_projectName").val(projectDetail.projectName);
					$("#treat_unitPrice").val(toDecimal(projectDetail.unitPrice));
					$("#treat_doctorCost").val(toDecimal(projectDetail.doctorCost));
					$("#treat_excutorCost").val(toDecimal(projectDetail.excutorCost));
					$("#treat_clinicCost").val(toDecimal(projectDetail.clinicCost));
					$("#treat_type").val(projectDetail.typeInt);
					$("#treat_status").val(projectDetail.statusInt);
					$("#treat_alterTime").val(projectDetail.alterTime);
					$("#treat_createTime").val(projectDetail.createTime);
					form.render();
				}
			}
			//费用项目
			if (category == 2) {
				$("#div_treat").css({
					"display" : "none"
				});
				//新增按钮
				if (operator == 1) {
					$(".div_time").css({
						"display" : "none"
					});
					$("#fund_status").attr("disabled", true);
					form.render();
				}
				//编辑按钮
				if (operator == 2) {
					var projectDetail = JSON.parse(localStorage.getItem("projectDetail"));
					$("#fund_projectName").val(projectDetail.projectName);
					$("#fund_type").val(projectDetail.typeInt);
					$("#fund_status").val(projectDetail.statusInt);
					$("#fund_alterTime").val(projectDetail.alterTime);
					$("#fund_createTime").val(projectDetail.createTime);
					form.render();
				}
			}
		}
	});
	
	//获取窗口数据
	function getParam() {
		var operator = localStorage.getItem("projectTable_operator");
		var category = localStorage.getItem("projectTable_category");
		//治疗项目
		if (category == 1) {
			//新增按钮
			if (operator == 1) {
				var param = {
					name : $("#treat_projectName").val(),
					category : "treatmentProject",
					unitPrice : $("#treat_unitPrice").val(),
					doctorCost : $("#treat_doctorCost").val(),
					clinicCost : $("#treat_clinicCost").val(),
					excutorCost : $("#treat_excutorCost").val(),
				};
				return param;
			}
			//编辑按钮
			if (operator == 2) {
				var projectDetail = JSON.parse(localStorage.getItem("projectDetail"));
				var param ={
					projectId : projectDetail.projectId,
					name : $("#treat_projectName").val(),
					category : "treatmentProject",
					unitPrice : $("#treat_unitPrice").val(),
					doctorCost : $("#treat_doctorCost").val(),
					clinicCost : $("#treat_clinicCost").val(),
					excutorCost : $("#treat_excutorCost").val(),
					type : $("#treat_type").val(),
					status : $("#treat_status").val(),
				};
				return param;
			}
		}
		//费用项目
		if (category == 2) {
			//新增按钮
			if (operator == 1) {
				var param = {
					name : $("#fund_projectName").val(),
					category : "fundProject",
					type : $("#fund_type").val(),
				};
				return param;
			}
			//编辑按钮
			if (operator == 2) {
				var projectDetail = JSON.parse(localStorage.getItem("projectDetail"));
				var param ={
					projectId : projectDetail.projectId,
					name : $("#fund_projectName").val(),
					category : "fundProject",
					unitPrice : "0.00",
					doctorCost : "0.00",
					clinicCost : "0.00",
					excutorCost : "0.00",
					type : $("#fund_type").val(),
					status : $("#fund_status").val(),
				};
				return param;
			}
		}
	}

	//数值设置
	function initFocusout() {
		$("#treat_unitPrice").focusout(function() {
			if (!toDecimal($(this).val())) {
				$(this).val(toDecimal(0.00));
			} else {
				$(this).val(toDecimal($(this).val()));
			}
		});
		$("#treat_doctorCost").focusout(function() {
			if (!toDecimal($(this).val())) {
				$(this).val(toDecimal(0.00));
			} else {
				$(this).val(toDecimal($(this).val()));
			}
		});
		$("#treat_excutorCost").focusout(function() {
			if (!toDecimal($(this).val())) {
				$(this).val(toDecimal(0.00));
			} else {
				$(this).val(toDecimal($(this).val()));
			}
		});
		$("#treat_clinicCost").focusout(function() {
			if (!toDecimal($(this).val())) {
				$(this).val(toDecimal(0.00));
			} else {
				$(this).val(toDecimal($(this).val()));
			}
		});
	}

	//强制保留两位小数 没0补0  四舍五入
	function toDecimal(x) {
		var f = parseFloat(x);
		if (isNaN(f)) {
			return false;
		}
		var f = Math.round(x * 100) / 100;
		var s = f.toString();
		if (isNaN(s)) {
			return false;
		}
		var rs = s.indexOf('.');
		if (rs < 0) {
			rs = s.length;
			s += '.';
		}
		while (s.length <= rs + 2) {
			s += '0';
		}
		return s;
	}
</script>
</html>
